/**
 * @summary 文章模块
 * @author 王翼
 * @summary ...
 */

import * as articleApi from '@/api/article';

export default {
  namespaced: true,
  state: {
    // 文章列表
    articleList: [],
    // 文章详情
    articleDetail: {},
  },
  mutations: {
    SET_ARTICLE_LIST(state, newValue) {
      state.articleList = newValue;
    },
    SET_ARTICLE_DETAIL(state, newValue) {
      state.articleDetail = newValue;
    },
  },
  actions: {
    async updateArticleList({ commit }, id) {
      const res = await articleApi.getArticleList(id);
      commit('SET_ARTICLE_LIST', res);
    },
    async updateArticleDetail({ commit }, id) {
      const res = await articleApi.getArticleDetail(id);
      commit('SET_ARTICLE_DETAIL', res);
    },
  },
}
